<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数求阶乘</title>
</head>

<body>
    <script>
        function getJC(n) {
            var resault = 1;
            for (var i = 1; i <= n; i++) {
                resault = resault * i;
            }
            return resault;
        }
        console.log('3的阶乘是' + getJC(3))

        function getSum(n) {
            var sum = 0;
            for (var i = 1; i <= n; i++) {
                sum = sum + getJC(i);
            }
            return sum;
        }
        console.log('\n' + '3的阶乘累加和是' + getSum(3))
    </script>
</body>

</html>